import unittest
from mox import *

from weektallier import *
from invoicer import *

class InvoicerTest(unittest.TestCase):
    
    def setUp(self):
        self.mockContext = Mox()
    
    def testInvoicerTalksToCalendarAndSpreadsheet(self):
        # Setup
        spreadsheetService = self.mockContext.CreateMock(SpreadsheetService) 
        calendarService = self.mockContext.CreateMock(CalendarService) 
        
        weeklyTotal = TimeTallier(2009, 1)
        weeklyTotal.addTimeBlock(1, 5.0)
        calendarService.getDailyTotalsForMonth(2009, 1).AndReturn(weeklyTotal)
        
        spreadsheetService.addWeek({1: 5.0, 2: 0.0, 3: 0.0, 4: 0.0, 5: 0.0, 6: 0.0, 7: 0.0})
        
        self.mockContext.ReplayAll()

        # Excercise
        invoicer = Invoicer(calendarService, spreadsheetService)
        invoicer.updateInvoiceForMonth(2009, 1)


        # Verify
        self.mockContext.VerifyAll()
        #invoicer = Invoicer("david.leblanc", "secret", spreadsheetService)
        #invoicer.updateInvoice(2008, 12)
